//
//  KABMallShoCarHeaderHFView.m
//  kabu
//
//  Created by XiangDongMBP on 2017/2/20.
//  Copyright © 2017年 East. All rights reserved.
//

#import "KABMallShoCarHeaderHFView.h"
#import "KABModel.h"

@implementation KABMallShoCarHeaderHFView

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    [self.selectBtn addTarget:self action:@selector(selBtnTapped:) forControlEvents:UIControlEventTouchUpInside];
    [self.deleteBtn addTarget:self action:@selector(delBtnTapped:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)selBtnTapped:(UIButton *)btn {
    if ([self.delegate respondsToSelector:@selector(kABMallShoCarHeaderHFView:section:selBtnTapped:)]) {
        [self.delegate kABMallShoCarHeaderHFView:self section:self.section selBtnTapped:btn];
    }
}

- (void)delBtnTapped:(UIButton *)btn {
    if ([self.delegate respondsToSelector:@selector(kABMallShoCarHeaderHFView:section:delBtnTapped:)]) {
        [self.delegate kABMallShoCarHeaderHFView:self section:self.section delBtnTapped:btn];
    }
}

- (void)configViewWithProDetail:(KABMallProDetail *)product couldSel:(BOOL)couldSel wholeSel:(BOOL)wholeSel {
    self.selectBtn.hidden = couldSel ? NO : YES;
    self.selBtnWidthConstraint.constant = couldSel ? 30.0 : 0.0;
    self.selectBtn.selected = wholeSel;
    
    self.nameLabel.text = product.shop_name;
    
    self.stateLabel.hidden = YES;
}

@end


@implementation KABMallShoCarHeaderHFView (MallOrderRelative)
- (void)configViewWithOrderDetail:(KABMallOrderDetail *)order couldSel:(BOOL)couldSel wholeSel:(BOOL)wholeSel {
    self.selectBtn.hidden = couldSel ? NO : YES;
    self.selBtnWidthConstraint.constant = couldSel ? 30.0 : 0.0;
    self.selectBtn.selected = wholeSel;
    
    self.nameLabel.text = order.shop_name;
    
    //!< 订单状态：0-全部订单 1-待付款 2-待发货 3-待收货 4-已收货 5-退货
    NSArray *titleArray = @[@"全部订单", @"待付款",@"待发货", @"待收货", @"已完成", @"退货"];
    self.stateLabel.hidden = NO;
    if (order.order_type < titleArray.count) {
        self.stateLabel.text = titleArray[order.order_type];
    }
}

@end
